<?php
include_once ("functions.php"); 
$user = new User();

//$userArray = array('admin','customer');
//checks if user_type is admin or customer
	//if(($_SESSION['user_type'] != 'admin') OR ($_SESSION['user_type'] != 'customer')):
	if($_SESSION['user_type'] != 'customer' || $_SESSION['user_type'] != 'admin'):
	{	
		User::validSession();
	}
	endif;

if ($_SERVER["REQUEST_METHOD"] == "POST") 
{ 
$login = $user->check_login($_POST['emailusername'], $_POST['password'], $_POST['user_type']);
if ($login) 
{
	switch($_SESSION['user_type']):
	
	case 'admin':
				$_SESSION['login'] = true;
				echo 'admin!!';
				break;
				
	case 'customer':
				$_SESSION['login'] = true;
				header('location:../view/sideBar.php');
				break;
				
	endswitch;
/*
if($_SESSION['user_type'] = 'admin'):
		
		
		echo 'admin!';
	elseif($_SESSION['user_type'] = 'customer'):
		
		echo 'customer';
	endif;

*/
// Login Success Admin
//echo 'Login success';
//echo User::test();
} 
else 
{
// Login Failed
echo 'Username / password wrong';

}
}
?>
